#!usr/bin/env python  
# -*- coding:utf-8 -*-
""" 
@author:robot
@file: solution.py 
@version:
@time: 2024/01/21 
"""
import sys


def find_indexes(input_string):
    if len(input_string) < 5 or len(input_string) > 30:
        return [0, 0]

    char_values = [ord(char) for char in input_string]
    total_sum = sum(char_values)

    begin = (total_sum - 122 * 2) // 3
    end = (total_sum - 97 * 2) // 3

    if begin < 0 or end < 0:
        return [0, 0]

    left_sum = 0
    left_index = 0
    result = [0, 0]

    # 从左侧找到第一个满足条件的索引位置
    while left_sum < end + 1:
        left_sum += char_values[left_index]
        left_index += 1
        if left_sum >= begin:
            right_sum = 0
            right_index = len(char_values) - 1

            # 从右侧找到第一个满足条件的索引位置
            while right_sum < end:
                right_sum += char_values[right_index]
                right_index -= 1

                # 使得字符串被这两个节点分成三个部分，每个部分的 ASCII 码的值之和都相等
                if (right_sum == left_sum == sum(
                        char_values[left_index + 1: right_index]) and left_index <= right_index):
                    result = [left_index, right_index]
                    break
            else:
                continue
            break

    return result


if __name__ == "__main__":
    """
    aabaacaa
    """
    input_string = sys.stdin.readline().strip()
    indexes = find_indexes(input_string)
    print(*indexes, sep=",")
